package com.tvein.web.controller.System
{
	//flash
	import flash.display.Loader;
	import flash.net.URLRequest;
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
	//custom
	import com.tvein.web.common.CommonConstants;
	import com.tvein.web.model.FilesProxy;
	import com.tvein.web.view.ApplicationMediator;
	import com.tvein.web.view.WebMediator;
//
	public class SystemGamePlay extends SimpleCommand implements ICommand
	{
		private var filesData:FilesProxy;
		private var appMediator:ApplicationMediator;
		
		override public function execute(notification:INotification) : void
		{
			filesData = facade.retrieveProxy(FilesProxy.NAME) as FilesProxy;
			appMediator = facade.retrieveMediator(ApplicationMediator.NAME) as ApplicationMediator;
			
			facade.removeMediator(WebMediator.NAME);
			
			var loader:Loader = new Loader();
			
			for (var i:int = 0; i < filesData.filesArray.length; i++)
			{
				if (filesData.filesArray[i][0].indexOf(notification.getBody().toString()) != -1)
				{
					loader.loadBytes(filesData.filesArray[i][1]);
					appMediator.web.addChild(loader);
					loader.x = loader.y = 0;
					break;
				}
			}
		}
	}
}